<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>火云鞋神订单中心</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/main.css">
    <link rel="stylesheet" href="../css/dd.css">
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .new-btn-login-sp {
            padding: 1px;
            display: inline-block;
            width: 75%;
        }

        .new-btn-login {
            background-color: #02aaf1;
            color: #FFFFFF;
            font-weight: bold;
            border: none;
            width: 100%;
            height: 30px;
            border-radius: 5px;
            font-size: 16px;
        }

        #main {
            width: 100%;
            margin: 0 auto;
            font-size: 14px;
        }

        .red-star {
            color: #f00;
            width: 10px;
            display: inline-block;
        }

        .null-star {
            color: #fff;
        }

        .content {
            margin-top: 5px;
        }

        .content dt {
            width: 100px;
            display: inline-block;
            float: left;
            margin-left: 20px;
            color: #666;
            font-size: 13px;
            margin-top: 8px;
        }

        .content dd {
            margin-left: 120px;
            margin-bottom: 5px;
        }

        .content dd input {
            width: 85%;
            height: 28px;
            border: 0;
            -webkit-border-radius: 0;
            -webkit-appearance: none;
        }

        #foot {
            margin-top: 10px;
            position: absolute;
            bottom: 15px;
            width: 100%;
        }

        .foot-ul {
            width: 100%;
        }

        .foot-ul li {
            width: 100%;
            text-align: center;
            color: #666;
        }

        .note-help {
            color: #999999;
            font-size: 12px;
            line-height: 130%;
            margin-top: 5px;
            width: 100%;
            display: block;
        }

        #btn-dd {
            margin: 20px;
            text-align: center;
        }

        .foot-ul {
            width: 100%;
        }

        .one_line {
            display: block;
            height: 1px;
            border: 0;
            border-top: 1px solid #eeeeee;
            width: 100%;
            margin-left: 20px;
        }

        .am-header {
            display: -webkit-box;
            display: -ms-flexbox;
            display: block;
            width: 100%;
            position: relative;
            padding: 7px 0;
            -webkit-box-sizing: border-box;
            -ms-box-sizing: border-box;
            box-sizing: border-box;
            background: #1D222D;
            height: 50px;
            text-align: center;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            box-pack: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            box-align: center;
        }

        .am-header h1 {
            -webkit-box-flex: 1;
            -ms-flex: 1;
            box-flex: 1;
            line-height: 18px;
            text-align: center;
            font-size: 18px;
            font-weight: 300;
            color: #fff;
        }
    </style>
</head>
<body>
<div class="container-fluid" style="background-color: white">
    <iframe src="../html/head.html" width="100%" height="260px" scrolling="no" name="iframe名称" style="border: 0">
    </iframe>

    <div class="address" style="">
        <div class="order-address OneRow" id="addressPC_1">
            <div class="header-wrapper border-bottom">
                <h2 class="header-title">
                    确认收货地址
                    <a href="#" class="header-operation" rel="noopener noreferrer" target="_blank">管理收货地址</a>
                </h2>
            </div>
        </div>
        <div class="address-list" id="address">
            <!--<div class="address-default">
                <input type="radio" role="radio" name="aa" tabindex="0" checked>
                <span>江苏省苏州市工业园区横塘街道若水路99号 17761928982 裴路洋收</span>
                <span style="font-weight: bold;margin-left: 20px">默认地址</span>
                <a href="#" style="float: right">修改本地地址</a>
            </div>
            <div class="address-other">
                <input type="radio" role="radio" name="aa" tabindex="0">
                <span>江苏省苏州市工业园区横塘街道若水路99号 17761928982 裴路洋收</span>
                <a href="#" style="display: none">设置为默认地址</a>
            </div>-->
        </div>

    </div>

    <div class="address" style="">
        <div class="order-address OneRow" id="addressPC_2">
            <div class="header-wrapper border-bottom">
                <h2 class="header-title">
                    优惠券
                     </h2>
            </div>
        </div>
        <div class="address-list" id="coupon">
            <!--<div class="address-default">
                <input type="radio" role="radio" name="aa" tabindex="0" checked>
                <span>江苏省苏州市工业园区横塘街道若水路99号 17761928982 裴路洋收</span>
                <span style="font-weight: bold;margin-left: 20px">默认地址</span>
                <a href="#" style="float: right">修改本地地址</a>
            </div>
            <div class="address-other">
                <input type="radio" role="radio" name="aa" tabindex="0">
                <span>江苏省苏州市工业园区横塘街道若水路99号 17761928982 裴路洋收</span>
                <a href="#" style="display: none">设置为默认地址</a>
            </div>-->
        </div>

    </div>


    <div style="position: relative;background-color: white;border-top: 2px dashed black;width: 1000px;margin-left: 20%" >
        <form name=alipayment action="http://localhost:8080/pay"  method=post
              target="_top">
            <div id="body1" class="show" name="divcontent">
                <dl class="content">
                    <dt>商户订单号 ：</dt>
                    <dd>
                        <input id="WIDout_trade_no" name="WIDout_trade_no" />
                    </dd>
                    <hr class="one_line">
                    <dt>订单名称 ：</dt>
                    <dd>
                        <input id="WIDsubject" name="WIDsubject" />
                    </dd>
                    <hr class="one_line">
                    <dt>付款金额 ：</dt>
                    <dd>
                        <input id="WIDtotal_amount" name="WIDtotal_amount" />
                    </dd>
                    <hr class="one_line">
                    <dt>商品具体信息：</dt>
                    <dd >
                        <input id="WIDbody" name="WIDbody" />
                    </dd>
                    <hr class="one_line">
                    <dt style="display:none">商品明细：</dt>
                    <dd style="display:none">
                        <input id="goodSize" name="goodSize" />
                        <input id="goodId" name="goodId" />
                        <input id="goodCounts" name="goodCounts" />
                        <input id="userId" name="userId" />
                    </dd>
                    <hr style="display:none" class="one_line">
                    <dt></dt>
                    <dd id="btn-dd">
						<span class="new-btn-login-sp">
							<button class="new-btn-login" type="submit"
                                    style="text-align: center;">付 款</button>
						</span> <span class="note-help">如果您点击“付款”按钮，即表示您同意该次的执行操作。</span>
                    </dd>
                </dl>
            </div>
        </form>
    </div>
    <div class="item-headers" id="orderDesc_orderDesc_1">
        <div class="header-wrapper ">
            <h2 class="header-title">确认订单信息</h2>
        </div>
        <div class="item-headers-wrap item-headers-column-6">
            <div class="item-headers-content item-headers-0">店铺宝贝</div>
            <div class="item-headers-content item-headers-1">商品属性</div>
            <div class="item-headers-content item-headers-2">单价</div>
            <div class="item-headers-content item-headers-3">数量</div>
            <div class="item-headers-content item-headers-4">优惠方式</div>
            <div class="item-headers-content item-headers-5">小计</div>
        </div>
    </div>
    <div class="dinamicx-card-group" id="order">
        <div class="seller">
            <div class="order-orderInfo">
                <img src="//img.alicdn.com/tps/i2/TB1wopUHVXXXXXyXpXXAAT2HVXX-63-63.png" class="shopIcon">
                <span class="shop-name">
                  店铺
                  :&nbsp
              </span>
                <a href="//store.taobao.com/shop/view_shop.htm?shop_id=112441448" target="_blank"
                   rel="noopener noreferrer" title="君君在韩国" class="order-link shop-url">火云鞋神</a>
                <span class="shop-seller">
                  卖家
                  :&nbsp
              </span>
                <a href="#">烦躁ing</a>
            </div>
        </div>
        <div style="padding: 0px; border-top: 1px solid rgb(255, 255, 255); width: 1000px;height: 91px;background-color: #5bc0de"></div>
    </div>

</div>

<script src="../js/cookie.js"></script>
<script src="../js/jquery-3.3.1.min.js"></script>
<script>
    var a = getCookie("userid")
    console.log(a)

    $.getJSON("http://localhost:8080/selectUser?userId=" + a, function (data) {
        var html = ''
        html += `
        <div class="address-default">
            <input type="radio" role="radio" name="aa" tabindex="0"  value="${data.userAddress} ${data.userPhone} ${data.userCard}" checked >
            <span>${data.userAddress} ${data.userPhone} ${data.userCard}</span>
            <a href="http://localhost:63343/qiguai/html/userperson.html" style="float: right">修改本地地址</a>
        </div>
        <div class="address-other">
            <input type="radio" role="radio" name="aa" tabindex="1"  value="${data.reserve2} ${data.reserve3} ${data.userCard}">
            <span>${data.reserve2} ${data.reserve3} ${data.userCard}</span>
            <a href="#" style="display: none">设置为默认地址</a>
        </div>
`
        $("#address").html(html)

        var z = $("input[name='aa']:checked").val()
        var addres = z.split(" ")
        document.getElementById("WIDbody").value=addres

        $(function(){
            $(":radio").click(function(){
                var z = $("input[name='aa']:checked").val()
                var addres = z.split(" ")
                document.getElementById("WIDbody").value=addres
            });
        });
        var w= $("#addr").html()
        console.log(w)



    })

    var search = location.search
    console.log(search)
    var arr = search.split("=")
    console.log(arr)
    var arr2 = arr[1].split(";")
    console.log(arr2)
    console.log(arr2.length)
    //将脑袋上的数据包装成数组，输出出来
    var arr3 = new Array(arr2.length)
    var arr4 = new Array(arr2.length)
    var arr5 = new Array(arr2.length)
    for (let i = 0; i < arr2.length; i++) {
        /*console.log()*/
        arr3[i] = arr2[i].split(",")[0]
        arr4[i] = arr2[i].split(",")[1]
        arr5[i] = arr2[i].split(",")[2]
    }
    console.log(arr3)
    console.log(arr4)
    console.log(arr5)
    var sum = 0;
    var arr6 = new Array(arr2.length)

    document.getElementById("goodSize").value=arr4
    document.getElementById("goodId").value=arr3
    document.getElementById("goodCounts").value=arr5
    document.getElementById("userId").value=a



    for (let j = 0; j < arr2.length; j++) {
        $.getJSON("http://localhost:8080/nb/selectById?id=" + arr3[j], function (data) {
            console.log(arr3[j])
            var html = ''
            html += `

            <div class="order-itemInfo" style="width: 100%;background-color:white;">
                <div class="info-detail info-cell">
                    <a href="#" target="_blank" rel="noopener noreferrer" class="order-link info-cell">
                        <img class="info-img"
                             src="${data.goodPhoto}"
                             alt="">
                    </a>
                    <div class="info-cell info-msg">
                        <a href="#" target="_blank" rel="noopener noreferrer" class="order-link info-title">
                            ${data.goodName}
                        </a>
                        <div class="info-icon-list">
                            <div>
                                <a href="//www.taobao.com/go/act/315/you.php" target="_blank" rel="noopener noreferrer"
                                   title="如实描述 - 消费者保障服务，卖家承诺商品如实描述" class="order-link icon-main">
                                    <img src="//gtd.alicdn.com/tps/i4/T1pegvFrBdXXaSQP_X-16-16.png" alt="">
                                </a>
                            </div>
                            <div>
                                <p class="icon-ext">
                                    支持7天无理由
                                    <a href="//service.taobao.com/support/knowledge-5701303.htm" target="_blank"
                                       rel="noopener noreferrer" class="order-link ext-detail-msg">详情</a>
                                </p>
                            </div>
                        </div>
                        <span class="delivery-time">
                        发货时间：
                        付款后3天内
                    </span>
                    </div>
                </div>
                <div class="info-sku info-cell">
                    <p>
                    <span class="hd">
                        鞋子尺码:
                    </span>
                        <span class="bd">${arr4[j]}</span>
                    </p>
                </div>
                <div class="info-price info-cell" >${data.goodMoney}</div>

            <div class="order-quantity">
                <div class="quantity-inner" >
                    <p>${arr5[j]}</p>
                </div>
            </div>
            <div class="item-row__select">
                <p>${data.goodUpper}</p>
            </div>
            <div class="item-row__price">
                <div class="label item-row__price-item">
                    <span style="font-weight: bold; font-style: normal; text-decoration: none; color: rgb(255, 68, 0); font-size: 14px; min-width: 100px;" >${parseInt(data.goodMoney)*parseInt(arr5[j])}</span>
                </div>
            </div>
            </div>
            `
            $("#order").append(html)
            sum  = parseInt(sum )+ parseInt(data.goodMoney)*parseInt(arr5[j])
            $("#money").html("￥" +sum)
            arr6[j] = data.goodMoney

            function GetDateNow() {
                var vNow = new Date();
                var sNow = "";
                sNow += String(vNow.getFullYear());
                sNow += String(vNow.getMonth() + 1);
                sNow += String(vNow.getDate());
                sNow += String(vNow.getHours());
                sNow += String(vNow.getMinutes());
                sNow += String(vNow.getSeconds());
                sNow += String(vNow.getMilliseconds());
                document.getElementById("WIDout_trade_no").value =  sNow;
                document.getElementById("WIDsubject").value = "火云鞋神鞋店订单";
                document.getElementById("WIDtotal_amount").value = sum;

            }
            GetDateNow();
        })
    }
</script>

<script>
    $.ajax({
        url: "http://localhost:8080/user/selectUCoupon",
        data: "currPage=" + 1 + "&pageSize=" + 100 + "&userId=" + a,
        asyne: false,
        dataType: "json",
        type: "get",
        success: function (data) {

            let html = ''
            var list = data.data.list

            for (let i = 0; i < list.length; i++) {
                var a = list[i].couponType.substring(1,4)

                if( parseInt(a ) < sum){
                    html += `
                <div class="address-other">
                <input type="radio" role="radio" onclick="you(this)" name="youhui" tabindex="0" value="${list[i].couponMoney}">
                <span>${list[i].couponType}</span>
            </div>
                `
                }

            }
            $("#coupon").append(html)
        }
    })

    function you() {
        var tmp1 = document.getElementsByName("youhui");
        var upper
        for(var i=0; i<tmp1.length; ++i)
            if(tmp1.item(i).checked){
                upper =	tmp1.item(i).getAttribute("value");
            }
        // alert(upper)
        document.getElementById("WIDtotal_amount").value = sum - upper
    }


    function f() {
        var q = $("#money").html()

        var z = $("#people").html()
        var x = q.substr(1);
    }

    var p = search.slice(1)
    console.log(p)
    if( p == "1"){
        parent.location.reload ="http://localhost:63343/qiguai/cart/cart.html？1"
    }

</script>

</body>
</html>